package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;

@Entity
@Table(name = "function_", schema = "crm")
public class Function {
    private int functionId;
    private String functionName;
    private String functionPath;
    private Integer funParentId;
    private Integer functionSort;
    private Integer functionLevel;
    private FunctionType functionType;

    @Id
    @Column(name = "function_id", nullable = false)
    public int getFunctionId() {
        return functionId;
    }

    public void setFunctionId(int functionId) {
        this.functionId = functionId;
    }


    @Basic
    @Column(name = "function_name", nullable = true, length = 255)
    public String getFunctionName() {
        return functionName;
    }

    public void setFunctionName(String functionName) {
        this.functionName = functionName;
    }

    @Basic
    @Column(name = "function_path", nullable = true, length = 255)
    public String getFunctionPath() {
        return functionPath;
    }

    public void setFunctionPath(String functionPath) {
        this.functionPath = functionPath;
    }

    @Basic
    @Column(name = "fun_parent_id", nullable = true)
    public Integer getFunParentId() {
        return funParentId;
    }

    public void setFunParentId(Integer funParentId) {
        this.funParentId = funParentId;
    }

    @Basic
    @Column(name = "function_sort", nullable = true)
    public Integer getFunctionSort() {
        return functionSort;
    }

    public void setFunctionSort(Integer functionSort) {
        this.functionSort = functionSort;
    }

    @Basic
    @Column(name = "function_level", nullable = true)
    public Integer getFunctionLevel() {
        return functionLevel;
    }

    public void setFunctionLevel(Integer functionLevel) {
        this.functionLevel = functionLevel;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Function function = (Function) o;
        return functionId == function.functionId &&
                Objects.equals(functionName, function.functionName) &&
                Objects.equals(functionPath, function.functionPath) &&
                Objects.equals(funParentId, function.funParentId) &&
                Objects.equals(functionSort, function.functionSort) &&
                Objects.equals(functionLevel, function.functionLevel);
    }

    @Override
    public int hashCode() {
        return Objects.hash(functionId, functionName, functionPath, funParentId, functionSort, functionLevel);
    }

    @ManyToOne
    @JoinColumn(name = "fun_type_id", referencedColumnName = "fun_type_id")
    public FunctionType getFunctionType() {
        return functionType;
    }

    public void setFunctionType(FunctionType functionType) {
        this.functionType = functionType;
    }


}
